<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activIds']))
{
	header("Location:checkLogin.php");
}
else
{
	$userId = ($_SESSION['s_activIds']);
  $m=0;
  $invoiceNoSelected = "";
  $contractArray = array();
  $selectContract = "SELECT DISTINCT invoice.contractId,userdoc.userId,invoice.invoiceId,invoice.invoiceNo
                       FROM invoice
                  LEFT JOIN userdoc on invoice.invoiceId = userdoc.invoiceId
                      WHERE userId = ".$userId."";
  if($_GET['contractId'] > 0)
  {
  	$invoiceNoSelected = ($_GET['invoiceId']);
    $selectContract .= " AND invoice.contractId = ".$_GET['contractId']."";
  }
  $selectContractRes = mysql_query($selectContract);
  while($contractRow = mysql_fetch_array($selectContractRes))
  {
  	$contractArray['invoiceId'][$m] = $contractRow['invoiceId'];
  	$contractArray['invoiceNo'][$m] = $contractRow['invoiceNo'];
  	$m++;
  }
  include("bottom.php");
  $smarty->assign("contractArray",$contractArray);
  $smarty->assign("invoiceNoSelected",$invoiceNoSelected);
  $smarty->display("getContrract.tpl");
}
?>